<script>
import CustomDialog from '@/components/custom-dialog/index.vue';
import MixinLists from './mixin'

export default {
  name: 'report-history-modal',
  components: {
    CustomDialog,
  },
  props: {
    year: {
      type: [String, Number],
      required: true,
    },
    quarter: {
      type: [String, Number],
      required: true,
    },
    tableId: {
      type: Number,
      required: true,
    }
  },
  data () {
    return {
    }
  },
  mixins: [MixinLists],
  methods: {
    open () {
      this.$refs.dialog.open()
    },
    getTableData () {
      this.getLists({
        pageNumber: this.pagination.pageNumber,
        pageSize: this.pagination.pageSize,
        tableId: this.tableId,
        tenantId: this.enterpriseId,
        year: this.year,
        quarter: this.quarter,
      })
    },
    async onOpen () {
      this.pagination.pageNumber = 1;
      await this.$nextTick();
      this.getTableData();
    },
  },
}
</script>

<template>
  <custom-dialog
    ref="dialog" title="查看历史操作" class="report-history-modal"
    :show-confirm-button="false" :show-cancel-button="false"
    @open="onOpen"
  >
    <el-table
      v-loading="loading"  :data="lists"
      height="40vh"
      :header-cell-style="{
        color: 'white',
        backgroundColor: themeColor,
      }"
    >
      <div slot="empty" class="empty-lists">
        <i class="i-custom:search"></i>
        <span class="empty-text">暂无数据</span>
      </div>
      <el-table-column label="时间" prop="time"></el-table-column>
      <el-table-column label="操作类型" prop="type"></el-table-column>
      <el-table-column label="操作人" prop="user"></el-table-column>
      <el-table-column label="备注" prop="remark"></el-table-column>
    </el-table>
    <el-pagination
      class="pagination" layout="total,prev,pager,next" background
      :current-page.sync="pagination.pageNumber" :page-size="pagination.pageSize"
      :total="pagination.total"
      @current-change="getTableData"
      @size-change="getTableData"
    ></el-pagination>
  </custom-dialog>
</template>

<style>
.report-history-modal .el-dialog__body {
  padding-top: 10px;
  padding-bottom: 10px;
}
.report-history-modal .pagination {
  margin-bottom: 30px;
}
</style>
